﻿mainModule.controller("articleAddCtrl", ["$scope", "$rootScope", "columnSvc", "notification", "pageState", "$routeParams", "articleSvc", "$location", function ($scope, $rootScope, columnSvc, notification, pageState, $routeParams, articleSvc, $location) {        
    var mode = "add";
    $scope.isColumnListVisible = false;
    $scope.article = {};
        
    $scope.save = function () {
        $scope.savedPressed = true;
        if ($scope.addListForm.$valid) {
            articleSvc.add($scope.article).then(function (response) {
                if (response.data.Success) {
                    $scope.article.ID = response.data.Value;
                    $scope.article.TypeID = 1;
                    $scope.$emit("articleAdded", $scope.article);
                    $location.path('/sitems/' + $scope.article.ID);
                    $scope.article = {};
                    $scope.savedPressed = false;
                }
                notification.notify(response.data);
            });
        }
    }                  
}]);




